import { defineStore } from 'pinia'

export const useUserStore = defineStore('user', {
  state: () => ({ userInfo: {}, token: '', count: 0 }),
  getters: {
    isLogin: (state) => state.token != '' && state.userInfo != {}
  },
  actions: {
    setToken(e) {
      this.token = e
    },
    setUserInfo(e) {
      this.userInfo = e
    },
    removeUserInfo() {
      this.token = ''
      this.userInfo = {}
    },
    addCount() {
      this.count++
    }
  }
})
